package com.ostrich.a2104gao5

import java.util.*


/**
 * @Author : yaotianxue
 * @Time : On 2023/10/13 16:14
 * @Description : Test6
 *
 * 面试的问题：kotlin中lambda表达式或高阶函数和java中接口回调
 * 比接口回调的优点？解决回调地狱问题
 */
fun main(){
    showOnBoard("牙膏"){goodsName:String,hour:Int ->
        "双十一促销 $goodsName 小时 $hour"
    }
}
fun showOnBoard(goodsName:String,getDiscountWords:(goodsName:String,hour:Int) -> String){
    val hour = Random().nextInt(24) //随机数

    val discountWords = getDiscountWords(goodsName, hour)
    println(discountWords)
}